#!/usr/bin/env python
# encoding: utf-8
"""
@author: shura
@position: saber
@contact: 2209032305@qq.com
@file: url.py
@time: 2019/3/9 11:01
@desc:
"""
l = int(input())
res = 0
def dfs(ss,cur,i,j):
    if i == len(ss) and j == len(ss[0]):
        res = max(ss[0][0]+cur, res)
    else:
        for i in range(len(ss)):
            for j in range(len(ss[0])):
                dfs(ss,ss[i][j]+cur,i+1,j+1)
for _ in range(l):
    m, n = map(int, input().split())
    nums = []
    for _ in range(m):
        nums.append(list(map(int, input().split())))
    res = 0


    print()

